package course.domain;

import java.util.ArrayList;
import course.domain.Course;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;


import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Data;


@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name="personal_course")
public class Personal {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;
	private Date placedAt; 
	private String SId;
	private String name;
	private String college;
	private int Grade;
	@ManyToMany(targetEntity = Course.class)
	private List<Course> selections = new ArrayList<>();
	public void addselection(Course list) {
		this.selections.add(list);
	}
	@PrePersist
	void placeAt() {
		this.placedAt=new Date();
	}
}
